package com.ll.mybatis.dao;

import com.ll.mybatis.bean.Employee;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 2020/9/18 - 10:10
 */
public interface EmployeeMapper {

    //查询单个员工
    public Employee getEmpById(Integer id);

    //mybaits允许增删改直接定义以下类型返回值
    //Integer, Long, Boolean
    //添加
    //public void addEmp(Employee employee);
    public Integer addEmp(Employee employee);

    //更新
    public Long updateEmp(Employee employee);

    //删除
    public Boolean deleteEmpById(Integer id);

    public Employee getEmpByIdAndLastName(@Param("id") Integer id, @Param("lastName") String lastNmae);

    public Employee getEmpByIdAndLastName2(Integer id, String lastNmae);

    public Employee getEmpByMap(Map<String, Object> maps);

    //查询,返回List集合
    public List<Employee> getEmpsByLastNameLike(String lastName);

    //查询,返回map, key就是列名, 值是对应的值
    public Map<String, Object> getEmpByIdReturnMap(Integer id);

    //查询,多条记录封装一map: Map<Integer, Employee>; key:主键, value:employee对象
    //告诉mybatis封装这个map的时候,使用哪个属性作为map的key
    @MapKey("id")
    public Map<Integer, Employee> getEmpByLastNameLikeReturnMap(String lastName);

}
